package com.aaa.sbms.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @FileName:CourseDao
 * @Description:
 * @Author :99728
 * @Date: 2020/6/16 19:12
 * @Version:1.0.0
 */
public interface CourseDao {

        /**
         * 分页带参查询课程管理列表
         */
        @Select("<script>select * from course"+
                "<where>" +
                " <if test='coursename!=null'> and coursename like '%${coursename}%' </if>"+
                "</where>order by courseid \n" +
                "limit #{begin},#{pageSize}</script>")
        List<Map> getPage(Map map);

        /**
         * 带参总条数查询课程管理
         * @param map
         * @return
         */
        @Select("<script>select count(*) from course  " +
                "<where>" +
                " <if test='coursename!=null'> and coursename like '%${coursename}%' </if>"+
                "</where></script>")
        int getPageCount(Map map);

        /**
         * 根据Id查寻信息
         * @param courseid
         * @return
         */
        @Select("select * from course where courseid = #{courseid}")
        Map onelist(int courseid);

        /**
         * 添加
         * @param map
         * @return
         */
        @Insert("insert into course (courseid,coursename,coursetype,coursedir,positionid) values" +
                "(null,#{coursename},#{coursetype},#{coursedir},#{positionid})")
        int add(Map map);

        /**
         * 更新
         * @param map
         * @return
         */
        @Update("update course set courseid=#{courseid},coursename=#{coursename},coursetype=#{coursetype},coursedir=#{coursedir},positionid=#{positionid} " +
                "where courseid=#{courseid}")
        int update(Map map);

        /**
         * 删除该ID关联的信息
         * @param courseId
         * @return
         */
        @Delete("delete from course where courseid=#{courseId}")
        int delete(Integer courseId);


}
